n = int(input())
cmds= [input() for i in range(2*n)]

def get_result(cmds):
    size=0
    issorted =True
    count=0
    for cmd in cmds:
        if "head add" in cmd:
            if size >0 and issorted:
                issorted =False
            size+=1
        elif "tail add" in cmd:
            size+=1
        else:
            if size<=0:
                continue
            if not issorted:
                count+=1
                issorted =True
            size-=1
    return count

print(get_result(cmds))